package com.theydream.qeechain.main;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.theydream.qeechain.R;

public class Tutorial extends Activity {
	private int tutorialImage[] = { R.drawable.tutorial_menu,
			R.drawable.tutorial_ar, R.drawable.tutorial_battle,R.drawable.tutorial_caught,R.drawable.tutorial_collection };

	ImageView mainImage;
	ImageView imageFinish;
	ImageView rightArrow;
	ImageView leftArrow;

	private int slide = 0;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tutorial);
		mainImage = (ImageView) findViewById(R.id.tutorial_image);
		imageFinish = (ImageView) findViewById(R.id.tutorial_finish);
		rightArrow = (ImageView) findViewById(R.id.tutorial_right_arrow);
		leftArrow = (ImageView) findViewById(R.id.tutorial_left_arrow);

		imageFinish.setVisibility(ImageView.INVISIBLE);

	}

	public void clickLeftArrow(View target) {
		if (slide == tutorialImage.length - 1) {
			mainImage.setImageResource(tutorialImage[--slide]);
			imageFinish.setVisibility(ImageView.INVISIBLE);
			rightArrow.setVisibility(ImageView.VISIBLE);
		}
		if (slide > 0) {
			mainImage.setImageResource(tutorialImage[--slide]);
		}

	}

	public void clickRightArrow(View target) {
		if (slide < tutorialImage.length - 2) {
			mainImage.setImageResource(tutorialImage[++slide]);
		} else if (slide < tutorialImage.length - 1) {
			mainImage.setImageResource(tutorialImage[++slide]);
			imageFinish.setVisibility(ImageView.VISIBLE);
			rightArrow.setVisibility(ImageView.INVISIBLE);
			imageFinish.setVisibility(ImageView.VISIBLE);
			leftArrow.setVisibility(ImageView.INVISIBLE);
		}
	}

	public void clickFinish(View target) {
		String PREF_NAME= "IsFirstGame";
		SharedPreferences prefSetting=getSharedPreferences(PREF_NAME,MODE_PRIVATE);
		SharedPreferences.Editor editor = prefSetting.edit();  
		   editor.putBoolean("FirstGame", false);  
		   editor.commit(); 
		   startActivity(new Intent (this,HomeMenuScreen.class));
		this.finish();
	}
}

// ImageView petImage = (ImageView) findViewById(R.id.pet_image);
// TextView petName = (TextView) findViewById(R.id.pet_name);
// TextView petDesc = (TextView) findViewById(R.id.pet_desc);
// TextView petTime = (TextView) findViewById(R.id.caught_time);
// TextView petS = (TextView) findViewById(R.id.strength);
// TextView petP = (TextView) findViewById(R.id.perception);
// TextView petE = (TextView) findViewById(R.id.endurance);
// TextView petC = (TextView) findViewById(R.id.charisma);
// TextView petI = (TextView) findViewById(R.id.intelligence);
// TextView petA = (TextView) findViewById(R.id.agility);
// TextView petL = (TextView) findViewById(R.id.luck);
// TextView petAddress = (TextView) findViewById(R.id.caught_address);
//
// // ===========================================
// // | Bind infomation to view
// // ===========================================
// if (bundle != null) {
// CaughtPet mPet = CaughtItemListClass.getInstance()
// .getItemList().get(bundle.getInt("id"));
//
// // get drawable resource by name
// petImage.setImageResource(getResources().getIdentifier(
// mPet.getPet().getPic(), "drawable",
// this.getPackageName()));
//
// GlobalData.getInstance().setCaughtPetImage(
// getResources().getIdentifier(mPet.getPet().getPic(),
// "drawable", this.getPackageName()));
//
// petName.setText(mPet.getPet().getName());
// petTime.setText(mPet.getTime());
// petDesc.setText(mPet.getPet().getDesc());
//
// Map<String, Integer> map = mPet.getPet().getAttr();
// petS.setText(map.get("S").toString());
// petP.setText(map.get("P").toString());
// petE.setText(map.get("E").toString());
// petC.setText(map.get("C").toString());
// petI.setText(map.get("I").toString());
// petA.setText(map.get("A").toString());
// petL.setText(map.get("L").toString());
//
// // ===========================================
// // | Location to Address
// // ===========================================
// Location location = new Location("Caught Location");
// location.setLatitude(Double.valueOf(mPet.getLat()));
// location.setLongitude(Double.valueOf(mPet.getLng()));
// double geoLatitude = location.getLatitude() * 1E6;
// double geoLongitude = location.getLongitude() * 1E6;
// GeoPoint gp = new GeoPoint((int) geoLatitude,
// (int) geoLongitude);
//
// Geocoder gc = new Geocoder(this, Locale.CHINA);
//
// double Latitude = (int) gp.getLatitudeE6() / 1E6;
// double Longitude = (int) gp.getLongitudeE6() / 1E6;
//
// List<Address> lstAddress;
// try {
// lstAddress = gc.getFromLocation(Latitude, Longitude, 1);
// if (lstAddress.size() > 0) {
// Address mAddress = lstAddress.get(0);
// petAddress.setText(mAddress.getAddressLine(1)
// .toString());
// }
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// }

